﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using WindowsForms.service;
using Model;
using WindowsForms.Class;

namespace WindowsForms
{
    public partial class HistoryManagement : DevExpress.XtraEditors.XtraForm
    {
        Service1 iQuery;
        List<HistoryMenus> lsHistoryMenus;
        List<HistoryBookings> lsHistoryBookings;

        public HistoryManagement()
        {
            iQuery = new Service1();
            InitializeComponent();

            dateEditTo.EditValue = DateTime.Now.AddDays(1);
            dateEditFrom.EditValue = DateTime.Now.AddDays(-7);

            GetHistory();
        }

        private void GetHistory()
        {
            ConvertToList convert = new ConvertToList();
            lsHistoryMenus = convert.ConvertTolistHistoryMenus(iQuery.SelectHistoryMenusAll().Tables[0]);
            gridControl1.DataSource = lsHistoryMenus;
        }

        private void simpleButton3_Click(object sender, EventArgs e)
        {
            ConvertToList convert = new ConvertToList();
         
            lsHistoryBookings = convert.ConvertTolistHistoryBookings(
                iQuery.SelectHistoryBookingByDateTime(String.Format("{0:yyyy-MM-dd}", dateEditFrom.DateTime), String.Format("{0:yyyy-MM-dd}", dateEditTo.DateTime)).Tables[0]);
            
            if (lsHistoryBookings != null && lsHistoryBookings.Count > 0)
            {
                gridControl2.DataSource = lsHistoryBookings;
            }
            else
            { 
                MessageBox.Show("Không có dữ liệu", "Lịch sử", MessageBoxButtons.OK);
            }
            
        }
    }
}